package com.yanqu.road.server.cmd.orewar.task;

import com.yanqu.road.entity.orewar.UserOrePit;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.BaseTask;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.orewar.OreWarMgr;
import com.yanqu.road.server.pb.OreWarPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

public class GetUserPitListTask extends BaseTask {

    private int activityId;

    private long userId;

    private List<UserOrePit> pitList;

    public int getActivityId() {
        return activityId;
    }

    public GetUserPitListTask(YanQuMessage packet, GamePlayer player) {
        super(packet, player);
    }

    @Override
    protected boolean parseData() throws Exception {
        OreWarProto.OreGetUserOrePitReqMsg reqMsg = OreWarProto.OreGetUserOrePitReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = reqMsg.getUserId();
        return true;
    }

    @Override
    protected void execute() {
        //校验查看用户是否在反击列表中
       /* if(OreWarMgr.isInOreWarRecord(activityId,player.getUserId(), userId)) {
            pitList = OreWarMgr.getUserOrePitList(activityId,userId);
        }*/
        pitList = OreWarMgr.getUserOrePitList(activityId,userId);

    }

    @Override
    protected void sendData(GamePlayer player) {
        OreWarProto.OrePitListMsg.Builder respMsg = OreWarPb.parseOrePitListMsg(pitList);
        respMsg.setActivityId(activityId);
        player.sendPacket(Protocol.U_ORE_WAR_GET_USER_PIT_DATA, respMsg);
    }

}
